package com.gite.nouette.admin.implementation.integrator.factory;

import com.gite.nouette.admin.contract.integrator.factory.IFactoryModel;
import com.gite.nouette.admin.contract.integrator.factory.IFactoryService;
import com.gite.nouette.admin.contract.model.IAdmin;
import com.gite.nouette.admin.contract.model.ICommand;
import com.gite.nouette.admin.contract.model.IContainerModule;
import com.gite.nouette.admin.contract.model.IHandlerModule;
import com.gite.nouette.admin.contract.model.IManager;
import com.gite.nouette.admin.contract.model.command.ICommandCreateModule;
import com.gite.nouette.admin.contract.model.command.ICommandModule;
import com.gite.nouette.admin.contract.model.command.ICommandRemoveModule;
import com.gite.nouette.admin.contract.model.command.IStateCommandActivation;
import com.gite.nouette.admin.contract.model.module.IModuleError;
import com.gite.nouette.admin.contract.model.module.IModuleLog;
import com.gite.nouette.admin.contract.observer.IObservable;
import com.gite.nouette.admin.implementation.model.AdminImpl;
import com.gite.nouette.admin.implementation.model.ContainerModuleImpl;
import com.gite.nouette.admin.implementation.model.HandlerModuleImpl;
import com.gite.nouette.admin.implementation.model.ManagerImpl;
import com.gite.nouette.admin.implementation.model.command.CommandCreateModuleImpl;
import com.gite.nouette.admin.implementation.model.command.CommandRemoveModuleImpl;
import com.gite.nouette.admin.implementation.model.command.StateCommandActiveImpl;
import com.gite.nouette.admin.implementation.model.command.StateCommandDesactiveImpl;
import com.gite.nouette.admin.implementation.model.module.ModuleErrorImpl;
import com.gite.nouette.admin.implementation.model.module.ModuleLogImpl;
import com.gite.nouette.admin.implementation.observer.ObservableImpl;

public class FactoryModelImpl implements IFactoryModel {

	private IFactoryService factoryService;

	@Override
	public IAdmin getAdmin() {
		return new AdminImpl();
	}

	@Override
	public IManager getManager() {
		return new ManagerImpl();
	}

	@Override
	public IHandlerModule getHandlerModule() {
		return new HandlerModuleImpl();
	}

	@Override
	public IContainerModule getContainerModule() {
		return new ContainerModuleImpl();
	}

	@Override
	public IModuleLog getModuleLog(ICommandModule... headerCommands) {
		ModuleLogImpl moduleLog = new ModuleLogImpl(headerCommands);
		moduleLog.setServiceASync(getFactoryService().getsServiceASync());
		return moduleLog;
	}

	@Override
	public IModuleError getModuleError(ICommandModule... headerCommands) {
		ModuleErrorImpl moduleError = new ModuleErrorImpl(headerCommands);
		moduleError.setServiceASync(getFactoryService().getsServiceASync());
		return moduleError;
	}

	@Override
	public ICommandCreateModule getCommandCreateModule() {
		return new CommandCreateModuleImpl();
	}

	@Override
	public ICommandRemoveModule getCommandRemoveModule() {
		return new CommandRemoveModuleImpl();
	}

	@Override
	public IStateCommandActivation getStateCommandActive() {
		return new StateCommandActiveImpl();
	}

	@Override
	public IStateCommandActivation getStateCommandDesactive() {
		return new StateCommandDesactiveImpl();
	}

	@Override
	public <O> IObservable<O> getObservable(O o) {
		return new ObservableImpl<O>(o);
	}

	@Override
	public IObservable<ICommand> getObservableCommand(ICommand command) {
		return getObservable(command);
	}

	/* GETTERS & SETTERS */

	public IFactoryService getFactoryService() {
		return factoryService;
	}

	public void setFactoryService(IFactoryService factoryService) {
		this.factoryService = factoryService;
	}

}
